
// Edit
var message = "";
$("[data-action=usetool]").on("click", "img", function(e) {

	$el = $(e.target).parent();
	if ($el.hasClass("grayscale")) {
		// apply grayscale
		image = Filters.getPixels(img);
		gray = Filters.grayscale(image);
		c = Filters.putPixels(gray, img.width, img.height);
		c.id = "cv01";
		$("#cv01").remove();
		$("[data-container=edit]").append(c);
	};

	if ($el.hasClass("brighten")) {
		// apply grayscale
		image = Filters.getPixels(img);
		gray = Filters.brightness(image, 50);
		c = Filters.putPixels(gray, img.width, img.height);
		c.id = "cv01";
		$("#cv01").remove();
		$("[data-container=edit]").append(c);
	};

	if ($el.hasClass("comment")) {
		// apply grayscale
		$(".text").fadeIn();
		$("[data-action=postcomment]").on("click", function() {
			$(".text").fadeOut();
			message = $(".text textarea").val();
		})

	};

	if ($el.hasClass("upload")) {
		// apply grayscale
		var c = $("#cv01")[0];
		c.toBlob(function(blob) {
			blob.name = filename;
			injectLocationAndUpload(blob);
	  	});
	};
})